/**
 * 列表页面的mixin
 */
import { SInput, STable } from '@/components'

export const ListMixin = {
  components: {
    STable, SInput
  },
  data () {
    return {
      queryParam: {}, // 表格的查询条件
      toggleSearchStatus: false, // 查询折叠
      selectedRowKeys: [], // table选中keys
      selectionRows: [] // table选中records
    }
  },
  methods: {
    /**
     * 清除table选中的数据
     */
    onClearSelected () {
      this.selectedRowKeys = []
      this.selectionRows = []
    },
    /**
     * 监听table的复选框
     * @param selectedRowKeys
     * @param selectionRows
     */
    onSelectChange (selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectionRows = selectionRows
    },
    /**
     * 查询面板折叠
     */
    handleToggleSearch () {
      this.toggleSearchStatus = !this.toggleSearchStatus
    },
    /**
     * 重置查询条件
     */
    searchReset () {
      this.queryParam = {}
      this.refreshTable()
    },
    /**
     * 表格刷新
     */
    refreshTable () {
      this.$refs.table.refresh(true)
    }
  }
}
